package com.example.demo.entity;

//import com.example.demo.listener.CardInsertListener;
//import com.example.demo.listener.CardListener;
//import com.example.demo.listener.CardUpdateListener;
//import com.example.demo.listener.LoggerListener;
import com.mybatisflex.annotation.*;
import com.mybatisflex.core.handler.Fastjson2TypeHandler;
import com.mybatisflex.core.mask.Masks;
import lombok.Data;

import java.time.LocalDateTime;
import java.util.Map;

//import com.example.demo.enum.com.example.demo.entity.TypeEnum; // enum 这样引入是报错的

@Data
@Table(value = "tb_card",
        camelToUnderline = false/*, // LoggerListener.class 全局配置了
        onInsert = {CardInsertListener.class}, //  1、onInsert = CardListener.class 用的是CardListener 2、 onInsert = CardInsertListener.class
        onUpdate = {CardUpdateListener.class}*/) //  1、onUpdate = CardListener.class 用的是CardListener 2、onUpdate = CardUpdateListener.class
public class Card {
    @Id(keyType= KeyType.Auto)
    private Long id;
    @ColumnMask("idNumber") // 自定义数据脱敏配置
    private String idNumber;
    private String location;
    @Column(onInsertValue = "NOW()") // now拼接到sql里 // 可能sql注入
    private LocalDateTime createTime;
    @Column(onUpdateValue = "NOW()") // onUpdateValue 和 监听器都有，以onUpdateValue为准
    private LocalDateTime updateTime;
    @Column(isLogicDelete = true) // 逻辑删除
    // private Boolean deleteFlag;
    private Integer deleteFlag;
    @Column(version = true) // 乐观锁
    private Integer version;
    @Column(tenantId = true) // 多租户
    private Integer tenantId;
    @Column(typeHandler = Fastjson2TypeHandler.class) // 类型处理器：要导入fastjson2依赖
    private Map<String, Object> options;
    @ColumnMask(Masks.EMAIL) // 数据脱敏
    private String email;
    private TypeEnum type; // 枚举属性 // 单独建一个enum目录，不知道怎么引入？？
}

// ctrl+shift+/ 多行注释
